/********************************************************************
	created:	2012/03/06
	created:	6:3:2012   20:17
	file ext:	cpp
	author:		wuxiangfei
*********************************************************************/

#include "stdafx.h"
#include "Mark.h"

#include "MarkDoc.h"
#include "MarkView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMarkView

IMPLEMENT_DYNCREATE(CMarkView, CView)

BEGIN_MESSAGE_MAP(CMarkView, CView)
	//{{AFX_MSG_MAP(CMarkView)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMarkView construction/destruction

CMarkView::CMarkView()
{
	// TODO: add construction code here

}

CMarkView::~CMarkView()
{
}

BOOL CMarkView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMarkView drawing

void CMarkView::OnDraw(CDC* pDC)
{
	CMarkDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here

	CString str;
	str.Format(_T("[CMarkView::OnDraw] pDoc->m_pBitap=%p.\n"), pDoc->m_pBitMap);

	EnterCriticalSection(&pDoc->m_CSBitmap);
	if (NULL != pDoc->m_pBitMap)
	{
		CDC MemDC;
		BITMAP bm;
		pDoc->m_pBitMap->GetBitmap(&bm);
		MemDC.CreateCompatibleDC(NULL);
		MemDC.SelectObject(pDoc->m_pBitMap);
		pDC->BitBlt(0, 0, bm.bmWidth, bm.bmHeight, &MemDC, 0, 0, SRCCOPY);
		MemDC.DeleteDC();
	}
	LeaveCriticalSection(&pDoc->m_CSBitmap);
}

/////////////////////////////////////////////////////////////////////////////
// CMarkView diagnostics

#ifdef _DEBUG
void CMarkView::AssertValid() const
{
	CView::AssertValid();
}

void CMarkView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CMarkDoc* CMarkView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMarkDoc)));
	return (CMarkDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMarkView message handlers
